package excelBase;

import java.util.ArrayList;

import lib.MergeInLib;
import lib.SheetInLib;

public class RowMember extends BaseContent
{
	private SheetInLib m_sheet;
	private RowContent m_rowContent;
	private Head m_head;
	
	public RowMember(SheetInLib sheet, Head head, RowContent content)
	{
		super(head.getName());
		m_children = new ArrayList<>();
		m_sheet = sheet;
		m_rowContent = content;
		m_head = head;
		makeChild();
	}
	
	private void makeChild()
	{
		int end = m_rowContent.getEnd();
		for(int i = m_rowContent.getStart(); i <= end; ++i)
		{
			String value = m_sheet.getRow(i).getCell(m_head.getStart()).getValue();
			MergeInLib merge = m_sheet.isMergeCell(i, m_head.getStart());
			if(merge != null)
			{
				i = merge.getY2();
			}
			m_children.add(new Cell(value));
		}
	}
}
